package com.ziyueyuwen.xiniao.controller.product.saler;

import com.ziyueyuwen.xiniao.base.HttpResContent;
import com.ziyueyuwen.xiniao.bean.product.SaleCourseDetailsQuery;
import com.ziyueyuwen.xiniao.bean.product.SaleCourseVO;
import com.ziyueyuwen.xiniao.bean.product.SaleDateParam;
import com.ziyueyuwen.xiniao.enums.GradeEnum;
import com.ziyueyuwen.xiniao.enums.ParamTypeEnum;
import com.ziyueyuwen.xiniao.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

import static com.ziyueyuwen.xiniao.base.BaseUtil.checkParam;
import static com.ziyueyuwen.xiniao.util.ConstUtil.PARAM_COURSE_ID;

/**
 * @author wancheng on 2019/4/4.
 */
@Controller
@RequestMapping("/product/sale")
@Validated
public class SaleController {

    @Autowired
    ProductService productService;

    @RequestMapping(value = "/course_details_params_time.do", method = RequestMethod.POST)
    public void courseDetailsParams(@Validated SaleCourseDetailsQuery paramQuery) throws Exception {
        HttpResContent<List<SaleDateParam>> hrc = new HttpResContent<>("销售查看课程列表");
        List<SaleDateParam> res = productService.getCourseDetailsParams(paramQuery);
        hrc.printLogAndResponse(res);
    }

    @RequestMapping(value = "/course_list.do", method = RequestMethod.POST)
    public void courseList(GradeEnum grade) throws Exception {
        HttpResContent<List<SaleCourseVO>> hrc = new HttpResContent<>("销售查看课程列表");
        List<SaleCourseVO> res = productService.productMsgForSale(grade);
        hrc.printLogAndResponse(res);
    }

    @RequestMapping(value = "/course_details.do", method = RequestMethod.POST)
    public void courseDetails(@Validated SaleCourseDetailsQuery query) throws Exception {
        HttpResContent<Map<String,Object>> hrc = new HttpResContent<>("销售查看课程列表");
        Map<String,Object> res = productService.courseDetailsForSale(query);
        hrc.printLogAndResponse(res);
    }

}
